package huoye.shops.huoye.message.fragment;


import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.SimpleAdapter;


import com.codeideology.android.lang.entity.Paging;
import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import huoye.shops.R;
import huoye.shops.base.BaseFragment;
import huoye.shops.base.PullToRefreshFragment;
import huoye.shops.huoye.message.adapter.MessageAdapter;
import huoye.shops.huoye.message.model.MessageShowData;
import huoye.shops.huoye.message.presenter.MessagePresenter;
import huoye.shops.huoye.message.view.IMessageRefreshView;
import huoye.shops.huoye.mine.activity.WithdrawActivity;
import huoye.shops.huoye.mine.activity.WithdrawEndActivity;
import huoye.shops.huoye.mine.model.PowerList;
import huoye.shops.huoye.operation.activity.ManageEventActivity;
import huoye.shops.huoye.operation.activity.ManagePrizeActivity;
import huoye.shops.huoye.operation.activity.ManageSellActivity;
import huoye.shops.huoye.operation.activity.OrderDetailsActivity;
import huoye.shops.huoye.operation.model.ManageEventData;
import huoye.shops.huoye.operation.model.SellOrder;

import static huoye.shops.huoye.operation.activity.ManagePrizeActivity.EXTRAS_KEY_PRIZE_TYPE;

/**
 * A simple {@link Fragment} subclass.
 */
public class MessageFragment extends PullToRefreshFragment<MessageShowData> implements IMessageRefreshView {


    private MessagePresenter mMessagePresenter;

    @Override
    public RecyclerViewAdapter createAdapter() {
        return new MessageAdapter(getActivity());
    }


    @Override
    public void onResume() {
        super.onResume();
        if(mMessagePresenter != null){
            query();
        }
    }

    @Override
    protected void initView(View view, @Nullable Bundle bundle) {
        mMessagePresenter = new MessagePresenter();
        mMessagePresenter.addTaskListener(this);
        mMessagePresenter.onStart();
       query();
    }

    @Override
    public void query(Paging paging) {
        super.query(paging);
        mMessagePresenter.postShopMessage(paging);
    }

    @Override
    public void onItemClick(MessageShowData messageShowData, int i, View view) {
        if(!messageShowData.isView()){
            mMessagePresenter.setShopMessage(messageShowData.getMsgId());
        }

       // 消息类型（1：便民信息审核 2：商家入驻审核 3：黑卡过期提示 4：订单状态提示 5:新留言回复 6:新活动开启 7:中奖消息 8:专属折扣释放 9:商家APP版本升级 10:新订单 11:活动状态 12:奖品审核 13:提现申请
        //          22:收入提醒    20:客户评价通知 = 20   14 :商家过期提醒
        switch (messageShowData.getMsgType()){
            case 1:

                break;
            case 2:

                break;
            case 3:

                break;
            case 4:
                SellOrder mSellOrder = new SellOrder();
                mSellOrder.setOrderId(messageShowData.getItemId()+"");
                startActivity(OrderDetailsActivity.class,mSellOrder);
                break;
            case 5:

                break;
            case 6:
                startActivityData(getActivity(),ManageEventActivity.class,false);
                break;
            case 7:

                break;
            case 8:

                break;
            case 9:

                break;
            case 10:
           //     startActivity(ManageSellActivity.class);

                SellOrder mSellOrderDetails = new SellOrder();
                mSellOrderDetails.setOrderId(messageShowData.getItemId()+"");
                startActivity(OrderDetailsActivity.class,mSellOrderDetails);

                break;
            case 11:
                startActivityData(getActivity(),ManageEventActivity.class,false);
                break;
            case 12:
                Intent intent = new Intent(getActivity(), ManagePrizeActivity.class);
                intent.putExtra(EXTRAS_KEY_PRIZE_TYPE,"2");
                startActivity(intent);
                break;
            case 13:
                startActivity(WithdrawActivity.class);
                break;
        }


    }






}
